<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basepath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>修改密码</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=yes" name="format-detection" />
    <link href="<%=basepath%>css/index.css" rel="stylesheet" type="text/css">
    <link href="<%=basepath%>css/join.css" rel="stylesheet" type="text/css">
    <script src="<%=basepath%>js/jquery-1.8.3.min.js"></script>
    <script src="<%=basepath%>js/layer/layer.js"></script>
</head>
<body>
<div class="viewport">
    <div class="header">
       <div class="header-1">
           <a href="javascrpt:void(0)" id="join" class="header-2">
              <span id="account" class="account">${empty user.realName ? '' : user.realName}</span>&nbsp;&nbsp;<span id="deptName" class="deptName">${user.departmentName}</span>
           </a>
           <a href="/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=mine&prefix=3g_mine&entrance=yes" class="back" id="back">返回</a>
           <span class="span-num">WWP11121</span>
       </div>
    </div>
    <div class="content m-top">
        <div class="blank-3"></div>
        <form method="post" id="myform" action="/wape-web/api/core/centerService">
            <div class="m-1-1"><input type="password" placeholder="请输入原密码" name="oldpwd" id="oldPwd"></div>
            <div class="m-1-1"><input type="password" placeholder="请输入新密码" name="pwd" id="newPwd"></div>
            <div class="m-1-1"><input type="password" placeholder="请确认新密码" id="again"></div>
            <div class="m-1-1 border"><a href="/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=forgot&prefix=3g" class="a-1">忘记密码？</a> </div>
            <div class="m-1-1 border"><input type="button" value="确定" class="submit" id="submit"></div>
            <div class="blank-2"></div>
        </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
     /*错误提示*/
     $(function(){
         var error = "${requestScope.returnMsg}";
         if(error != "" && error != "成功!"){
             layer.msg(error,{shadeClose:true,shade:0.1,time:2000});
         }
     });
     /*修改密码*/
     $(function(){
    	 $("#submit").click(function(){
    		 layer.confirm("确定提交？",{icon:3,title:"修改密码"},function(){
    			 $("#myform").submit();
    		 });
    	 });
    	 $("#myform").submit(function(){
    		 var oldPwd = $("#oldPwd").val();
    		 var newPwd = $("#newPwd").val();
    		 var again = $("#again").val();
    		 if(oldPwd == ""){
    			 layer.msg("请填写原密码",{shadeClose:true,shade:0.1,time:2000});
    			 return false;
    		 }
    		 else if(newPwd==""){
                 layer.msg("请输入新密码",{shadeClose:true,shade:0.1,time:2000});
                 return false;
             }
             else if(newPwd.length<6){
                 layer.msg("新密码不能少于6个字符",{shadeClose:true,shade:0.1,time:2000});
                 return false;
             }
             else if(newPwd.length>20){
                 layer.msg("新密码不能大于20个字符",{shadeClose:true,shade:0.1,time:2000});
                 return false;
             }
             else if(again==""){
                 layer.msg("请再次输入新密码",{shadeClose:true,shade:0.1,time:2000});
                 return false;
             }
             else if(password!=again){
                 layer.msg("两次密码不一致",{shadeClose:true,shade:0.1,time:2000});
                 return false;
             }
             else{
            	 var d = $("#oldPwd").val();
            	 var e = $.md5($.md5($.md5(d)));
            	 var b = $("#newPwd").val();
                 var c = $.md5($.md5($.md5(b)));
                 $("#oldPwd").val(e);
                 $("#newPwd").val(c);
                 layer.load();
                 setTimeout(function(){
               	  layer.closeAll();
               	  layer.msg("网络异常，请重新尝试！",{shadeClose:true,shade:0.1,time:2000});
               	}, 30000);
             }
    	 });
     });
</script>
</html>

